home *** CD-ROM | disk | FTP | other *** search
- Path: howland.reston.ans.net!psinntp!psinntp!psinntp!psinntp!usenet
- From: grantp@usa.pipeline.com(Pete Grant)
- Newsgroups: comp.lang.c++
- Subject: Re: socket problem ...
- Date: 21 Mar 1996 21:54:44 GMT
- Organization: Kalevi, Inc.
- Message-ID: <4isj74$ato@news1.h1.usa.pipeline.com>
- References: <315181A4.7266@mitretek.org>
- NNTP-Posting-Host: 38.8.120.15
- X-PipeUser: grantp
- X-PipeHub: usa.pipeline.com
- X-PipeGCOS: (Pete Grant)
- X-Newsreader: Pipeline v3.5.0
-
- On Mar 21, 1996 11:19:48 in article <socket problem ...>, 'Chris Irwin
- <cirwin@mitretek.org>' wrote:
-
-
-
- >I have a server daemon process that is leaving the socket bound upon
- >exiting. It is actually a C++ program using the socket++-1.10 class
- >library but uses the usual socket library calls. When I kill the server
- >and try to restart it, it seems that the port is still in use. Basically
- >the server does a fork() after the accept(). THe parent process closes
- >the new socket and the child process closes the original socket does its
- >thing and then exit() s. Any help would be greatly appreciated.
- >
- >Thanks in advance
- Chris: I tried to e-mail but it bounced, so I'll post it:
- I do mostly TLI, but have done some raw socket programming also. I
- have found no problems of "stuck" ports since doing the following:
-
- void disconnect(int socket)
- {
- struct linger lx = { 1, 0 };
- if (setsockopt(socket, SOL_SOCKET, SO_LINGER, (char*)&lx, sizeof(lx)))
- myerrormessageandexit("error...");
- close(socket);
- exit(1);
-
- If setting the SO_LINGER doesn't do it for you, post your
- question to comp.unix.programmer where guys like Rich Stevens
- hang out (R Stevens is the author of Unix Network Programming).
-
- --
- Pete Grant
- Kalevi, Inc.
- Software Engineering & development
-